const path = require('path');
// 生成html的插件
const htmlWebpackPlugin = require('html-webpack-plugin');
// 压缩的插件
const uglifyjsWebpackPlugin = require('uglifyjs-webpack-plugin');
const webpack = require('webpack');
module.exports = {
	entry: './main.js',
	output: {
		path: path.resolve(__dirname, 'dist'),
		filename: 'index.js'
	},
	mode: 'development',
	module: {
		rules: [{
				test: /\.css$/,
				use: ['style-loader', 'css-loader']
			},
			{
				test: /\.less$/,
				use: ['style-loader', 'css-loader', 'less-loader']
			},
			{
				test: /\.(png|jpg|gif)$/,
				use: [{
					loader: 'url-loader',
					options: {
						limit: 8192
					}
				}]
			}
		]
	},
	plugins: [
		new htmlWebpackPlugin(),
		new uglifyjsWebpackPlugin(),
		new webpack.HotModuleReplacementPlugin()
	],
	devServer: {
		contentBase: path.join(__dirname, "dist"),
		compress: true,
		port: 9000,
		hot: true,
		// 配置代理,用来跨域
		proxy: {
			'/v4': {
				target: 'https://m.maizuo.com',
				// 允许跨域
				changeOrigin: true,
				pathRewrite: {
					'^/v4': '/v4'
				}
			}
		}
	}

}